<template>
  <div id="index">
    <dv-full-screen-container class="bg">
      <dv-loading v-if="loading">Loading...</dv-loading>
      <div v-else class="host-body">
        <div class="d-flex jc-center body_title">
          <dv-decoration-10 style="width:33.3%;height:.0625rem;" />
          <div class="d-flex jc-center">
            <dv-decoration-8 :color="['#568aea', '#000000']" style="width:2.5rem;height:.625rem;" />
            <div class="title">
              <span class="title-text">11111111</span>
              <dv-decoration-6
                class="title-bototm"
                :reverse="true"
                :color="['#50e3c2', '#67a1e5']"
                style="width:3.125rem;height:.1rem;"
              />
            </div>
            <dv-decoration-8
              :reverse="true"
              :color="['#568aea', '#000000']"
              style="width:2.5rem;height:.625rem;"
            />
          </div>
          <dv-decoration-10 style="width:33.3%;height:.0625rem; transform: rotateY(180deg);" />
          <!-- 时间 -->
            <div
              class="react-left mr-4"
              style=" background-color: #0f1325; text-align: right;"
            >
              <span class="react-after"></span>
              <span class="text">{{timeValue}}</span>
            </div>
          <!-- </div> -->
        </div>

        <!-- body总盒子 -->
        <div class="body-box">
          <div class="body_left">
            <div class="lefttop">
              <!--监控1-->
              <div class="lefttop1">
                <lefttop1></lefttop1>
              </div>
              <!--监控2-->
              <div class="lefttop2">
                <lefttop2></lefttop2>
              </div>
            </div>

            <div class="leftmiddle">
              <!--一周日产量-->
              <div class="leftmiddle1">
                <leftmiddle1></leftmiddle1>
              </div>
              <!--一周设备日开动率-->
              <div class="leftmiddle2">
                <leftmiddle2></leftmiddle2>
              </div>
            </div>
            <div class="leftbotton">
              <!--半年月产量-->
              <div class="leftbotton1">
                <leftbotton1></leftbotton1>
              </div>
              <!-- 总产量趋势图 -->
              <div class="leftbotton2">
                <leftbotton2></leftbotton2>

              </div>

            </div> 
          </div>
          <div class="body_right">
            <!--设备警报-->
            <div class="right_top">
              <righttop></righttop>
            </div>
            <!--设备运行状态-->
            <div class="right_botton">
              <rightbotton></rightbotton>
            </div>
          </div>
        </div>
      </div>
    </dv-full-screen-container>
  </div>
</template>

<script>
import lefttop1 from "./lefttop1";
import lefttop2 from "./lefttop2";
import leftmiddle1 from "./leftmiddle1";
import leftmiddle2 from "./leftmiddle2";
import leftbotton1 from "./leftbotton1";
import leftbotton2 from "./leftbotton2";
import righttop from "./righttop";
import rightbotton from "./rightbotton";











export default {
  data() {
    return {
      loading: true,
      timeValue:''
    };
  },
  components: {
    lefttop1,
    lefttop2,
    leftmiddle1,
    leftmiddle2,
    leftbotton1,
    leftbotton2,
    righttop,
    rightbotton,

  },
  mounted() {
    this.cancelLoading();
    this.displayTime();
    if (this.timer) {
      clearInterval(this.timer);
    }
    this.timer = setInterval(() => {
      this.displayTime();
    }, 1000)

  },
  methods: {
    cancelLoading() {
      setTimeout(() => {
        this.loading = false;
      }, 500);
    },
    // 不足两位补零
     addZero(num,length) {
      return (Array(length).join('0')+num).slice(-length)
    },
    displayTime() {
      //获取系统当前的年、月、日、小时、分钟、毫秒
      let date, year, month, day, h, m, s;
      date = new Date();
      year = date.getFullYear();
      month = date.getMonth() + 1;
      day = date.getDate();
      h = this.addZero(date.getHours(),2); 
      m = this.addZero(date.getMinutes(),2);
      s = this.addZero(date.getSeconds(),2);

      return this.timeValue = year + "-" + month + "-" + day + "  " + h + ":" + m + ":" + s;
    }
  }
};
</script>

<style lang="scss">
@import "../assets/scss/index.scss";
</style>